import Vue from 'vue'
import VueRouter from 'vue-router'

const Problem_list= () => import('../views/problem_list/Problem_list.vue')
const Problem = () => import('../views/problem_detail/problem_detail.vue')
Vue.use(VueRouter)


//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  routes: [
    {
      path: '/',
      component: Problem_list,
    },
    {
      path: '/problems_list',
      component: Problem_list,
    },
    {
      path: '/problem/:id',
      component: Problem,
    }

  ],
  mode: 'history'
})

export default router